package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.OrderBom;
import com.indusfo.spc.service.OrderBomService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author liub
 * @Date 2019/11/26 10:54
 * @Version 1.0
 */

@Controller
@RequestMapping(value = "/service/orderBom")
public class OrderBomController {

    @Autowired
    private OrderBomService orderBomService;

    /**
     * 查询
     */
    @RequestMapping(value = "/queryOrderBom")
    @ResponseBody
    public JSONObject queryOrderBom(OrderBom orderBom) {
        JSONObject json = orderBomService.queryOrderBom(orderBom);
        return json;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/insertOrderBom", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertOrderBom(OrderBom orderBom) {
        JSONObject json = orderBomService.insertOrderBom(orderBom);
        return json;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/updateOrderBom", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateOrderBom(OrderBom orderBom) {
        JSONObject json = orderBomService.updateOrderBom(orderBom);
        return json;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/deleteOrderBom", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteOrderBom(@RequestParam("orderBomIds") List<Integer> orderBomIds, Integer dataState) {
        dataState = 2;
        JSONObject json = orderBomService.deleteOrderBom(orderBomIds, dataState);
        return json;
    }

    /**
     * 启停
     */
    @RequestMapping(value = "/definedOrderBom", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject definedOrderBom(@RequestParam("orderBomIds") List<Integer> orderBomIds, Integer dataState) {
        JSONObject json = orderBomService.deleteOrderBom(orderBomIds, dataState);
        return json;
    }
}
